package com.zx.JDK特性.jdk_17;

/**
 * 密封类和接口限制哪些其他类或接口可以扩展或实现它们。
 */
public sealed interface Shape {

    void run();

    final class Planet implements Shape {

        @Override
        public void run() {
            System.out.println("Planet");
        }
    }

    final class Star implements Shape {

        @Override
        public void run() {
            System.out.println("Star");
        }
    }

    final class Comet implements Shape {

        @Override
        public void run() {
            System.out.println("Comet");
        }
    }
}
